# -*- coding:utf-8 -*-
"""
Author：Administrator
Date:2022年01月01日
"""
import requests
from bs4 import BeautifulSoup
import time

url = 'https://www.umei.cc/bizhitupian/weimeibizhi/'
resp = requests.get(url)
resp.encoding = 'utf-8'
# print(resp.text)
main_page = BeautifulSoup(resp.text,'html.parser')
alist=main_page.find('div',class_="TypeList").find_all('a')
# print(alist)
for a in alist:
	href = "https://www.umei.cc"+a.get('href')
	child_page_resp = requests.get(href)
	child_page_resp.encoding = 'utf-8'
	child_page_text = child_page_resp.text
	child_page = BeautifulSoup(child_page_resp.text,'html.parser')
	p = child_page.find('p',align='center')
	img = p.find('img')
	src = img.get('src')
	img_resp = requests.get(src)
	img_resp.content # 这里拿到的是字节
	img_name = src.split('/')[-1]
	with open('img/'+img_name,mode='wb') as f:
		f.write(img_resp.content)
	time.sleep(1)
	print('over',img_name)
	
print('over!')

